import {
  RECORD_USERINFO,
  OUT_LOGIN,
  RECORD_TOKEN
} from './mutation-types.js'

import { setStore, removeStore } from './storage-utils'

export default {

  // 记录用户信息
  [RECORD_USERINFO] (state, info) {
    state.userInfo = info
    setStore('userInfo', info)
  },
  // 记录用户TOKEN
  [RECORD_TOKEN] (state, token) {
    state.token = token
    setStore('token', token)
  },
  // 退出登录
  [OUT_LOGIN] (state) {
    state.userInfo = null
    state.token = null
    removeStore('userInfo')
    removeStore('token')
  }

}
